<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="font-awesome/css/font-awesome.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen animated fadeInDown" id="ycapp" v-cloak>
        <div>
            <div>
                <h1 class="logo-name">YC</h1>
            </div>
            </p>
            <p v-if="error">{{ errorMsg }}</p>
            <div class="form-group">
                <input type="text" v-model="username" class="form-control" placeholder="Username" required="">
            </div>
            <div class="form-group">
                <input type="password" v-model="password" class="form-control" placeholder="Password" required="">
            </div>
            <button type="button" @click="login" class="btn btn-primary block full-width m-b">Login</button>
            <p class="m-t"> <small>Y U N C &copy; 2017</small> </p>
        </div>
    </div>

    <!-- Mainly scripts -->
    <script src="js/jquery-2.1.1.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/vue.min.js"></script>
    <script src="js/common.js"></script>
	<script>
        var vm = new Vue({
            el:'#ycapp',
            data:{
                username:'',
                password:'',
                error:false,
                errorMsg:'Login'
            },
            methods:{
                login:function () {
                    var data = "username="+vm.username+"&userpassword="+vm.password;
                    $.ajax({
                        type: "POST",
                        url: baseURL + "login/ajaxLogin",
                        data: data,
                        dataType: "json",
                        success: function(r){
                            if(r.code == 'success'){//登录成功
                                localStorage.setItem("token", r.msg);
                                parent.location.href ='index.html';
                            }else{
                                vm.error = true;
                                vm.errorMsg = r.msg;
                            }
                        }
                    });
                }
            }
        });
	</script>
</body>
</html>
